What does the following assignment statement statement do:

sum = 42 - 12 ;

A good answer might be:

It: (1) evaluates the expression, which yields 30; then (2) puts that value in the variable sum.

Expressions

Normally you would say:

The statement puts 30 into sum.

However, you must understand that two steps take place, in order. When the expression on the right gets complicated you need to know the two steps to figure out what happens.

An expression is a combination of literals, operators, variables, and parentheses used to calculate a value.

This (slighly incomplete) definition needs some explanation:

This might sound awful. Actually, this is stuff that you know from algebra, like:

(32 - y) / ( x + 5 )

In the above, the character "/" means "division." Not just any mess will work (of course). The following:

32 - y) / ( x  5 + )

is not a syntactically correct expression. There are rules for this, but the best rule is that an expression must look OK as algebra.

QUESTION 12:

Which of the following expressions are correct?

53 12 - 3) x + 34 ((rats - 3) / 45 sum * 3 + 2
-79.4 (foo - 7) z 99 ((x+y)/(y+92) -3) +6 x ** -4 +